<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <div id="app">
        <input type="button" value="添加数据" @click="add">
        <input type="button" value="移除数据" @click="remove">
        <ul>
            <li v-for="(item,index) in arr">
                {{index+1}}黑马：{{item}}
            </li>
            <h2 v-for="item in objarr" :title="item.name">
                {{item.name}}
            </h2>
        </ul>
    </div>
    <script src="http://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
    <script>
        var app = new Vue({
            el: '#app',
            data: {
                arr: ["北京", "上海", "深圳"],
                objarr: [{
                        name: "1111"
                    },
                    {
                        name: "2222"
                    }
                ]
            },
            methods: {
                add: function () {
                    this.objarr.push({
                        name: "333"
                    })
                },
                remove: function () {
                    this.objarr.shift();
                }
            }
        })
    </script>
</body>

</html>